﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using Mr.LinqToWeibo.SearchCriteria;

namespace Mr.LinqToWeibo
{
    internal class WeiboDataQueryProvider<T>
        : IWeiboDataQueryProvider<T>
    {
		private WeiboContext context = new WeiboContext();
		
        public IQueryable<TElement> CreateQuery<TElement>(Expression expression)
        {
            return (IQueryable<TElement>)new QueryableWeiboData<T>(this, expression);
        }

        public IQueryable CreateQuery(Expression expression)
        {
            return this.CreateQuery<T>(expression);
        }

        public TResult Execute<TResult>(Expression expression)
        {
            return (TResult)context.Execute<T>(
				expression, this.WeiBoScope, this.AccessToken, this.AccessTokenSecret, this.UseObjectFilter);
        }

        public object Execute(Expression expression)
        {
            return context.Execute<T>(
				expression, this.WeiBoScope,this.AccessToken, this.AccessTokenSecret, this.UseObjectFilter);
        }

        #region IWeiboDataQueryProvider<TCriteria> Members

        public Scope WeiBoScope { internal get; set; }
		
		public string AccessToken { internal get; set; }
		
		public string AccessTokenSecret { internal get; set; }
		
		public bool UseObjectFilter{ internal get; set; }

        #endregion
    }
}
